<?php
require_once "WXconfig.php";

header("Content-type: text/html; charset=UTF-8");


$myfile = fopen("payBack.log", "a") or die("Unable to open file!");
 $Md5=Configs::SIGNATURE;
$post_data = array(
"transDate" => $_POST['transDate'],
"transTime" =>$_POST['transTime'],
"merchno" =>$_POST['merchno'],
"merchName" =>$_POST['merchName'],
//"customerno" =>$_POST['customerno'],
"openId"=>$_POST['openId'],
"amount" =>$_POST['amount'],
"traceno" => $_POST['traceno'],
"payType" =>$_POST['payType'],
"orderno" =>$_POST['orderno'],
"channelOrderno" => $_POST['channelOrderno'],
"channelTraceno" =>$_POST['channelTraceno'],
"status" =>$_POST['status'],
);

//签名操作

ksort($post_data);
$a='';
foreach($post_data as $x=>$x_value)
{
	if($x_value){
			$a=$a.$x."=".$x_value."&";
	}

}

fwrite($myfile, "--------------------------------start--------------------------------\n");

fwrite($myfile, date('y-m-d H:i:s',time())."接收到的数据:".file_get_contents("php://input"));
fwrite($myfile, "\n");


$b=md5($a.$Md5);

$c=$_POST['signature'];
fwrite($myfile, date('y-m-d H:i:s',time())."加密完成的字段:".$c."\n");
$d=strtoupper($b);
if($d==$c){
	fwrite($myfile, date('y-m-d H:i:s',time())."返回的数据:"."success\n");
	echo "success";
	
}else{
	echo "fail";
	fwrite($myfile, date('y-m-d H:i:s',time())."返回的数据:"."fail\n");
}

fwrite($myfile, "----------------------------------end--------------------------------\n");

fclose($myfile);





?>